package nl.harmidi.midi;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * This service will use a Thread pool to perform the given tasks.
 * 
 */
public class ThreadPoolingService {

	private ExecutorService service;

	private int coreAmountOfThreads = 50;

	private int roofAmountOfThreads = 250;

	private int keepAliveOnTopOfCoreSeconds = 30;

	public ThreadPoolingService() {
		service = new ThreadPoolExecutor(coreAmountOfThreads, roofAmountOfThreads, keepAliveOnTopOfCoreSeconds, TimeUnit.SECONDS,
				new LinkedBlockingQueue<Runnable>());
	}

	public void execute(Runnable task) {
		service.execute(task);
	}

}
